package com.wgj.android.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.jiaai.xui.utils.http.ListHttpCallBack;
import com.jiaai.xui.utils.http.XHttp;
import com.wgj.android.R;
import com.wgj.android.adapter.MyShopStoreAdapter;
import com.wgj.android.entity.ShopStore;
import com.wgj.android.http.WGJAPI;
import com.wgj.android.utils.CacheUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018\5\4 0004.
 */

public class MyShopStoreActivity extends AppCompatActivity {
    @BindView(R.id.recycler_view)
    RecyclerView recyclerView;

    private List<ShopStore> shopStoreList = new ArrayList<>();
    private MyShopStoreAdapter myShopStoreAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setContentView(R.layout.activity_my_shop_store);
        ButterKnife.bind(this);
        myShopStoreAdapter = new MyShopStoreAdapter(recyclerView, shopStoreList);
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setAdapter(myShopStoreAdapter);
        loadShopStores();
    }

    private void loadShopStores() {
        XHttp.obtain().get(WGJAPI.BASEURL + "shop/findMyShop/" + CacheUtils.getMember().getM_id(), null, new ListHttpCallBack<ShopStore>() {
            @Override
            public void onSuccess(List<ShopStore> list) {
                shopStoreList.addAll(list);
                myShopStoreAdapter.notifyDataSetChanged();
            }

            @Override
            public void onFailed(int i, String s, boolean b) {

            }
        });
    }
    @OnClick(R.id.tv_apply_shop)
    public void applyShop(View v){
        //XXXWebActivity.getINT(this,WGJAPI.ASSETSURL+"createStore?userId="+CacheUtils.getMember().getM_id(),"");
    }
}
